package com.yiyang.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import com.yiyang.constant.ResultCode;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
    private Integer code;

    private T data;

    private String msg;

    public static <T> Result<T> success(T data){
        return new Result<T>(ResultCode.SUCCESS,data,"success!");
    }

    public static <T> Result<T> success(){
        return new Result<T>(ResultCode.SUCCESS,null,"success!");
    }

    public static <T> Result<T> fail(T data,String msg){
        return new Result<T>(ResultCode.ERROR,data,msg);
    }

    public static <T> Result<T> fail(Integer code,T data,String msg){
        return new Result<T>(code,data,msg);
    }
    public static <T> Result<T> fail(Integer code,String msg){
        return new Result<T>(code,null,msg);
    }
}
